package copyengine.ui.component.button.animation.mobile
{
	import com.fl.motion.AdjustColor;
	
	import flash.display.DisplayObject;
	import flash.events.MouseEvent;
	import flash.filters.ColorMatrixFilter;
	import copyengine.ui.component.button.animation.ICEButtonAnimation;

	/**
	 * 用于Mobile
	 *
	 * 1·只响应MouseDown,MouseUp事件而忽略RollOver和RollOut事件
	 * 2·Dark: 在按下按钮时候会调整按钮的对比度,使其整体颜色变暗
	 *
	 */
	public class CEMobileButtonDarkAnimation implements ICEButtonAnimation
	{
		//按下按钮时候默认调整的对比度,如果有contrastNum参数则覆盖该值
		private var contrastNum:int=-70;

		protected var targetMc:DisplayObject;

		public function CEMobileButtonDarkAnimation(_arg:Object=null)
		{
			if (_arg)
			{
				_arg["contrastNum"] != null ? contrastNum=_arg["contrastNum"] : null
			}
		}

		public function setTarget(_buttonBg:DisplayObject):void
		{
			targetMc=_buttonBg;
		}

		public function dispose():void
		{
		}

		public function onMouseUp(e:MouseEvent):void
		{
			targetMc.filters=null;
			targetMc.scaleX=targetMc.scaleY=1;
		}

		public function onMouseDown(e:MouseEvent):void
		{
			//------------------
			//--设置对比度
			//------------------
			var colorAdjust:AdjustColor=new AdjustColor();
			colorAdjust.brightness=0; // 亮度
			colorAdjust.contrast=contrastNum; //对比度
			colorAdjust.saturation=0; //饱和度
			colorAdjust.hue=0 //色相
			targetMc.filters=[new ColorMatrixFilter(colorAdjust.CalculateFinalFlatArray())];
		}

		public function onMouseRollOver(e:MouseEvent):void
		{
		}

		public function onMouseRollOut(e:MouseEvent):void
		{
			targetMc.filters=null;
		}
	}
}
